﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;

namespace InstantSpine.Core.MaterialModels
{
    /// <summary>
    /// Isotropic linear elastic material
    /// </summary>
    [DataContract]
    public sealed class IsoLinearElasticMaterial: MaterialViewModel
    {        
        private double? youngsModulus;
        private double? poissonsRatio;

        // read/write for two-way binding
        /// <summary>
        /// Young’s modulus
        /// </summary>
        [DataMember]
        public double? YoungsModulus { 
            get { return youngsModulus; }
            set {                
                if (youngsModulus != value) {
                    youngsModulus = value;
                    OnPropertyChanged();
                }
            }
        }

        // read/write for two-way binding
        /// <summary>
        /// Poisson’s ratio
        /// </summary>
        [DataMember]
        public double? PoissonsRatio {
            get { return poissonsRatio; }
            set {
                if (poissonsRatio != value) {
                    poissonsRatio = value;
                    OnPropertyChanged();
                }
            }
        }
       
        /// <summary>
        /// Create a new isotropic linear elastic material model
        /// </summary>
        /// <param name="ym">Young’s modulus</param>
        /// <param name="pr">Poisson’s ratio</param>
        public IsoLinearElasticMaterial(double ym, double pr, string name): base(name) {
            this.youngsModulus = ym;
            this.poissonsRatio = pr;
        }

        /// <summary>
        /// Create an "empty" linear elastic model, i.e. E = nu = name = null
        /// </summary>
        public IsoLinearElasticMaterial(string name = null): base(name) {
            this.youngsModulus = null;
            this.poissonsRatio = null;
        }

        // required for XML serialization to work
        public IsoLinearElasticMaterial() : this(null) { }
    }
}
